<?php 

/*$str = "学并思官网www.xuebingsiwang.com学并思论坛  http://bbs.xuebingsiwang.com我在学并思的网名叫xuebingsi";
$preg = "/(xuebingsi)wang/";

$c= preg_match_all($preg,$str,$res);
var_dump($c);
	
var_dump($res);*/

/*$str=file_get_contents('https://www.lagou.com/');

$preg="/data-lg-tj-cid=\"\d{7}\">(.+)<span>/";

$c=preg_match_all($preg, $str, $res);

var_dump($c);

var_dump($res);*/

$str=file_get_contents('http://search.51job.com/list/000000,000000,0000,00,9,99,php,2,1.html?lang=c&degreefrom=99&stype=&workyear=99&cotype=99&jobterm=99&companysize=99&radius=-1&address=&lonlat=&postchannel=&list_type=&ord_field=&curr_page=&dibiaoid=0&landmark=&welfare=');
$preg="/<a target=\"_blank\" title=\"(.+)\"/";
$c=preg_match_all($preg, $str, $aaa);
/*var_dump($c);
var_dump($aaa);*/

/*<a target="_blank" title="PHP开发工程师" href="http://jobs.51job.com/shenzhen-lgq/86843119.html?s=01&amp;t=0" onmousedown=""></a>*/




// $str = "学并思官网www.xuebingsiwang.com学并思论坛  http://bbs.xuebingsiwang.com我在学并思的网名叫xuebingsi";
// $preg = "/(xuebingsi)wang/is";
// $c = preg_match_all($preg, $str,$res); //pattern, subject, matches是原型 为输出变量  $c为匹配到的次数
// var_dump($c);
// var_dump($res);
// echo $res[1][1];



// preg_split()方法
// 通过一个正则表达式分隔字符串
// 语法：
// array preg_split ( string $pattern , string $subject)

// $c = preg_split($preg, $str); 
// var_dump($c);
// array (size=3)
//   0 => string '学并思官网www.' (length=19)
//   1 => string '.com学并思论坛  http://bbs.' (length=32)
//   2 => string '.com我在学并思的网名叫xuebingsi' (length=40)



//  采集
$str = file_get_contents('https://www.lagou.com/');  //获取百度路径字符串,用正则匹配字符串里的内容就是采集\
//$str = iconv("gb2312", "utf-8//IGNORE",$str);  //出现乱码可用此函数
//var_dump($str);
$preg = "/<a href=\"https:\/\/www\.lagou\.com\/jobs\/\d{7,}\.html\" target=\"\w{6,}\" class=\"position_link fl wordCut\" data-index=\"\d+\" data-lg-tj-id=\"[A-z0-9]{4,}\" data-lg-tj-no=\"\d{4,}\" data-lg-tj-cid=\"\d{7,}\">(.+)<\/span><\/a>/";

// $c = preg_match_all($preg, $str, $res);
// var_dump($c);
// var_dump($res);

$str = file_get_contents('http://society.huanqiu.com/article/2017-06/10878802.html?from=bdwz');
$preg = "/<strong>浙江24小时-钱江晚报记者 汪子芳 通讯员 郭志刚<\/strong>(.+)<!--相关新闻上方合作 begain-->/is";

$c = preg_match_all($preg, $str, $res);
var_dump($c);
var_dump($res);

//file_put_contents('./db.php', $res[1][0]);



 ?>